package com.chushouya.manager.dao.repository;

import com.chushouya.manager.dao.entity.ActivityLogEntity;
import com.chushouya.manager.dto.admin.activity.ActivityLogQuery;
import com.chushouya.manager.dto.admin.activity.ActivityQuery;
import com.general.framework.core.lang.Strings;
import com.general.framework.data.mybatis.BaseRepository;
import com.chushouya.manager.dao.entity.ActivityEntity;
import com.chushouya.manager.dao.mapper.ActivityEntityMapper;
import com.chushouya.manager.dto.admin.article.ArticleApiQuery;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

@Repository
public class ActivityRepository extends BaseRepository<ActivityEntityMapper, ActivityEntity, Long> {

    private Example buildExample(ActivityQuery query) {
        Example example = buildExample();
        Example.Criteria c = example.and();
        if (query.getActivityId() != null) {
            c.andEqualTo("activityId", query.getActivityId());
        }
        if (Strings.isNotEmpty(query.getTicketNo())) {
            c.andEqualTo("ticketNo", query.getTicketNo());
        }
        return example;
    }
    public ActivityEntity selectOne(ActivityQuery query) {
        Example example = buildExample(query);
        return selectFirstOneByExample(example);
    }

}
